<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
html,body {
	margin: 0;
	padding: 0;
	border: 0;
	width: 100%;
	height: 100%;
}
</style>
<script src="../scripts/boot.js" type="text/javascript"></script>
</head>

<body>
	<div class="mini-toolbar">
		<a class="mini-button" plain="true" onclick="preview" iconcls="icon-new">查看备注</a>
		<a class="mini-button" plain="true" visible="false" onclick="edit" id="btn_edit" iconcls="icon-edit">填报备注</a>
		<a class="mini-button" plain="true" visible="false" onclick="audit" id="btn_audit" iconcls="icon-user">审核</a>
		<a class="mini-button" plain="true" visible="false" onclick="overToday" id="btn_overToday" iconcls="icon-ok">查验</a>
	</div>
	<div class="mini-fit"><!-- onrowdblclick="edit" 双击事件 -->
		<div id="datagrid1" class="mini-datagrid" allowResize="false" pageSize="20" url="listData?status=${status}"
			style="width:100%;height:100%;" borderStyle="border-top:none;" idField="id" multiSelect="true"
		>
			<div property="columns">
				<div field="number" width="100" headerAlign="center" align="left" allowSort="false">案号</div>
				<div field="caseType" width="50" headerAlign="center" align="left" allowSort="false" renderer="exchangeCaseType">案件类别</div>
				<div field="reason" width="100" headerAlign="center" align="left" allowSort="false">立案案由</div>
				<div field="userName" width="50" headerAlign="center" align="left" allowSort="false">承办人</div>
				<div field="eventType" width="50" headerAlign="center" align="left" allowSort="false" renderer="exchangeEventType">事件类型</div>
				<div field="remainDays" width="30" headerAlign="center" align="left" allowSort="false">剩余天数</div>
				<div field="overdueDays" width="30" headerAlign="center" align="left" allowSort="false">逾期天数</div>
				<div field="status" width="50" headerAlign="center" align="left" allowSort="false" renderer="exchangeStatus">状态</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
var basepath = window.location.pathname + "/../";
var roleIds = "${roleIds}";
//初始化
mini.parse();
var grid = mini.get("datagrid1");
grid.load();
$(function (){
	if(roleIds.indexOf("1") >= 0){
		mini.get("btn_audit").setVisible(true);
		mini.get("btn_overToday").setVisible(true);
	}
	if(roleIds.indexOf("2") >= 0){
		mini.get("btn_edit").setVisible(true);
	}
});
function exchangeCaseType(e){
	var caseType = e.row.caseType;
	if(caseType == '1'){
		return "民事案件";
	}else if(caseType == '2'){
		return "刑事案件";
	}else if(caseType == '3'){
		return "执行案件";
	}else if(caseType == '4'){
		return "行政案件";
	}else{
		return "";
	}
}
function exchangeStatus(e){
	var status = e.row.status;
	if(status == '0'){
		return "<span style='color:lightseagreen;'>正常</span>";
	}else if(status == '1'){
		return "<span style='color:orangered;'>未处理</span>";
	}else if(status == '2'){
		return "<span style='color:lightskyblue;'>已填报</span>";
	}else if(status == '3'){
		return "<span style='color:limegreen;'>已处理</span>";
	}else if(status == '4'){
		return "<span style='color:darkred;'>已退回</span>";
	}else{
		return "";
	}
}

function exchangeEventType(e){
	var status = e.row.eventType;
	if(status == '1'){
		return "<span style='color:orange;'>预警</span>";
	}else if(status == '2'){
		return "<span style='color:orangered;'>逾期</span>";
	}
}

//新增
function add() {
	mini.open({
		url : basepath+"add",
		title : "新增展览明细",
		width : 1000,
		height : 800,
		allowResize: false,
		onload : function() {
			
		},
		ondestroy : function(action) {
			if (action == "save") {
				grid.reload();
			}
		}
	});
}
//编辑
function edit() {
	var row = grid.getSelected();
	if(row == null){
		mini.alert("请选择一条记录");
		return;
	}
	if(row.status!='1' && row.status!='4'){
		mini.alert("该记录无需填报");
		return;
	}
	mini.open({
		url : basepath+"edit",
		title : "填报",
		width : 450,
		height : 320,
		allowResize: false,
		onload : function() {
			var iframe = this.getIFrameEl();
			iframe.contentWindow.SetData(row);
		},
		ondestroy : function(action) {
			if (action == "save") {
				grid.reload();
			}
		}
	});
}

function preview() {
	var row = grid.getSelected();
	if(row == null){
		mini.alert("请选择一条记录");
		return;
	}
	mini.open({
		url : basepath+"preview",
		title : "查看备注",
		width : 450,
		height : 320,
		allowResize: false,
		onload : function() {
			var iframe = this.getIFrameEl();
			iframe.contentWindow.SetData(row);
		},
		ondestroy : function(action) {
			if (action == "save") {
				grid.reload();
			}
		}
	});
}
//审核
function audit() {
	var row = grid.getSelected();
	if(row == null){
		mini.alert("请选择一条记录");
		return;
	}
	if(row.status!='2'){
		mini.alert("该记录无需审核");
		return;
	}
	mini.open({
		url : basepath+"audit",
		title : "查看备注",
		width : 450,
		height : 320,
		allowResize: false,
		onload : function() {
			var iframe = this.getIFrameEl();
			iframe.contentWindow.SetData(row);
		},
		ondestroy : function(action) {
			if (action == "save") {
				grid.reload();
			}
		}
	});
}
//删除
function remove() {
	var rows = grid.getSelecteds();
	if(rows == null || rows.length<=0){
		mini.alert("请选择一条记录");
		return;
	}
	mini.showMessageBox({
		title: "提示",
		width: 250,
		buttons: ["ok", "cancel"],
		message: "确认删除选中的记录吗？",
		iconCls: "mini-messagebox-question",
		callback: function (action) {
			if (action == "ok") {
				executeRemove(rows);
			}
		}
	});
}
//执行删除
function executeRemove(rows){
	var ids = [];
	for ( var i = 0, l = rows.length; i < l; i++) {
		var r = rows[i];
		ids.push(r.id);
	}
	var id = ids.join(',');
	mini.mask({
		el: document.body,
		cls: 'mini-mask-loading',
		html: '正在处理，请耐心等待 ...'
	}); 

	$.ajax({
		url : "delete",
		type : "post",
		data : {
			ids : id
		},
		success : function(text) {
			mini.unmask();
			var result = mini.decode(text);
			if (result.res) {
				grid.reload();
			} else {
				mini.showMessageBox({
					title : "提示",
					width : 250,
					buttons : ["ok"],
					iconCls : "mini-messagebox-warning",
					message : result.msg
				});
			}
		},
		error : function(jqXHR, textStatus, errorThrown) {
			mini.unmask();
			alert(jqXHR.responseText);
		}
	});
}
//筛选
function search(){
	mini.open({
		url : basepath+"search",
		title : "筛选",
		width : 800,
		height : 280,
		allowResize : false,
		ondestroy : function (action) {
			if(action == "search"){
				var iframe = this.getIFrameEl();
				var data = iframe.contentWindow.GetData();
				console.log(data);
				data = mini.clone(data);
				grid.load(data);
			}
		}
	});
}
//导入Excel
function importExcel() {
	mini.open({
		url : basepath+"import",
		title : "导入展览明细数据",
		width : 400,
		height : 200,
		allowResize : false,
		ondestroy : function (action) {
			if(action='ok'){
				grid.reload();
			}
		}
	});
}
//导出Excel
function exportExcel(){
	mini.confirm("确定导出记录？", "导出",
		function (action) {
			if (action == "ok") {
				executeExport();
			} else {
			}
		}
	);
}
//执行导出
function executeExport(){
	var data = grid.getLoadParams();
	mini.mask({
		el: document.body,
		cls: 'mini-mask-loading',
		html: '正在导出...'
	});
	$.ajax({
		url : "export",
		type : "post",
		data : data,
		dataType : "json",
		success : function(resultBean) {
			mini.unmask();
			if(resultBean.res){
				window.location.href = resultBean.data;
			}else{
				mini.alert(resultBean.msg);
			}
		},
		error : function(redata) {
			mini.unmask();
		}
	});
}

function overToday(){
	mini.mask({
		el: document.body,
		cls: 'mini-mask-loading',
		html: '正在处理'
	});
	$.ajax({
		url : "overToday",
		type : "post",
		data : {},
		dataType : "json",
		success : function(resultBean) {
			mini.unmask();
			if(resultBean.res){
			}else{
				mini.alert(resultBean.msg);
			}
		},
		error : function(redata) {
			mini.unmask();
		}
	});
}

//查看详情
function detail() {
	var row = grid.getSelected();
	if (row == null) {
		mini.alert("请选择一条记录");
		return;
	}
	mini.open({
		url: basepath + "detail",
		title: "详情",
		width: 800,
		height: 572,
		allowResize: false,
		onload: function () {
			var iframe = this.getIFrameEl();
			iframe.contentWindow.SetData(row);
		},
		ondestroy: function (action) {
			if (action == "save") {
				grid.reload();
			}
		}
	});
}
//查看报名

function userDetail(){
	var row = grid.getSelected();
	if(row == null){
		mini.alert("请选择一条记录");
		return;
	}

	let url;
	if(row.type == '1'){
		url = basepath+"user_confirm_list?id="+row.id;
	}else{
		url = basepath+"team_confirm_list?id="+row.id;
	}
	mini.open({
		url : url,
		title : "报名记录",
		width : 1000,
		height : 600,
		allowResize: false,
		onload : function() {
			var iframe = this.getIFrameEl();
			iframe.contentWindow.SetData(row);
		}
	});
}


</script>
</body>
</html>
